import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.util.concurrent.TimeUnit;

/**
 * 通过门户登录，点数智豫电图标，到数字化平台，再跳转到河南
 *
 * @author admin
 */
public class Brush_Szh_Szhn {
    public static void main(String[] args) {

        //指定配置
        System.setProperty("webdriver.chrome.driver", "drivers/chromedriver.exe");

        //隐藏浏览器
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.addArguments("--start-maximized");

        //声明浏览器
        ChromeDriver driver = new ChromeDriver(chromeOptions);

        //数字化平台登录
        driver.get("http://iscsso.sgcc.com.cn/isc_sso/login?service=http://open.sgcc.com.cn/pi6000-ua-web/api/daptValidate?target=http://open.sgcc.com.cn");
        driver.findElement(By.id("department")).click();
        driver.findElement(By.className("tab_item2")).click();
        driver.findElement(By.linkText("河南电力")).click();

        driver.findElement(By.id("username")).sendKeys("zhuying6");
        driver.findElement(By.id("password")).sendKeys("zhuying=789");
        driver.findElement(By.id("submit_login")).click();
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        driver.getPageSource();

        String windowHandleSzh = driver.getWindowHandle();
        System.out.println("数字：" + windowHandleSzh);


        //各省
        driver.findElement(By.linkText("各省")).click();

        //河南
        driver.findElement(By.cssSelector(".content-box:nth-child(14) > i")).click();

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        driver.quit();  // 关闭浏览器
    }

}
